package com.hertz.alarm.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface GenericDAO {

    <T extends AbstractEntity> void save(T entity);

    <T extends AbstractEntity> void update(T entity);

    <T extends AbstractEntity> void saveOrUpdate(T entity);

    <T extends AbstractEntity> void merge(T entity);

    <T> T getUniqueResult(String name, Object... params);
    
    <T> T getUniqueResultByParamMap(final String name,final Map<String, Object> paramMap);

    <T extends AbstractEntity<ID>, ID extends Serializable> void delete(T entity);
    
    <T extends AbstractEntity<ID>, ID extends Serializable> void delete(ID id, Class<T> clazz);

    <T extends AbstractEntity<ID>, ID extends Serializable> T get(ID id, Class<T> clazz);

    <T extends AbstractEntity<ID>, ID extends Serializable> Map<ID, T> getMulti(Collection<ID> ids, Class<T> clazz);

    <T> List<T> listByParamMap(final String name,final int firstResult,final int maxResults,final Map<String, Object> paramMap);
    
    <T> List<T> listByParams(final String name,final int firstResult,final int maxResults,final Object... params);
    
    <T> List<T> listByParamsToMap(final String name,final int firstResult,final int maxResults,final Object... params);

    <T> List<T> listAll(final String name,final Object... params);
    
    <T> List<T> listAll(Class<T> clazz);

    <T extends AbstractEntity> void saveOrUpdateAll(Collection<T> entities);

    <T extends AbstractEntity<ID>, ID extends Serializable> List<T> toEntityList(List<ID> idList, Class<T> clazz);
    
    Integer executeUpdate(String name,Object ... params);
} 
